﻿using System;
using System.Runtime.InteropServices;

namespace _63_自定义义隐式转换_类型转换
{
    class Program
    {
        static void Main(string[] args)
        {
            RectArea v = new RectArea(12, 15);

            int area = v;

            Console.WriteLine($"矩形信息：\n 宽：{v.Width}\n 高：{v.Height} \n 面积：{area}");

        }
    }


    public class RectArea
    {
        public RectArea(int width, int height)
        {
            Width = width;
            Height = height;
        }

            public int Width { get; set; }
        public int Height { get; set; }

    //添加自定义转换类
    public static implicit operator int (RectArea r)
    {
        return r.Width * r.Height;
    }

    }
}
